package br.com.sigarota.facade;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration;

import br.com.sigarota.dao.PontoDAO;
import br.com.sigarota.dao.TransmissaoDAO;
import br.com.sigarota.modelo.Ponto;
import br.com.sigarota.modelo.Transmissao;

public class TransmissaoFacadeImpl implements TransmissaoFacade {

	private static final long serialVersionUID = 1818242808424001885L;

	private TransmissaoDAO transmissaoDao;
	private SessionFactory sf; 
	private	Session session;
	private Transaction tx;

	public void salva(Transmissao p) {
		sf = new AnnotationConfiguration().configure().buildSessionFactory(); 
		session = sf.openSession();
		tx = session.beginTransaction();
		transmissaoDao = new TransmissaoDAO(session, Transmissao.class);
		this.transmissaoDao.save(p);
		tx.commit();
		session.close();
	}

	public List<Transmissao> lista() {
		this.sf = new AnnotationConfiguration().configure().buildSessionFactory(); 
		this.session = sf.openSession();
		this.tx = session.beginTransaction();
		this.transmissaoDao = new TransmissaoDAO(this.session, Transmissao.class);
		List<Transmissao> lista = this.transmissaoDao.list();
		this.tx.commit();
		this.session.close();
		return lista;
	}

	public void remove(Transmissao t) {
		// TODO Auto-generated method stub
		
	}

	public Transmissao procura(Long id) {
		// TODO Auto-generated method stub
		return null;
	}

	public void atualiza(Transmissao t) {
		// TODO Auto-generated method stub
		
	}
}